package common.Exception;

public class Results <T>{
    private  boolean isSuccess;
    private String message;
    private T data;

    public Results(boolean isSuccess, String message, T data) {
        this.isSuccess = isSuccess;
        this.message = message;
        this.data = data;
    }


    public boolean isSuccess() {
        return isSuccess;
    }

    public void setSuccess(boolean success) {
        isSuccess = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Results() {
        this.data = null;
    }

    public Results<T> success(T data, String message){
        this.data = data;
        this.message = message;
        this.isSuccess = true;
        return this;
    }
    public Results<T> fail(T data,String message){
        this.data = data;
        this.message = message;
        this.isSuccess = false;
        return this;
    }

    public Results<T> success(String message){
        this.message = message;
        this.isSuccess = true;
        return this;
    }

    public Results<T> fail(String message){
        this.data = null;
        this.message = message;
        this.isSuccess = false;
        return this;
    }
}
